package utils

import (
	"encoding/json"
	"strconv"
)

// 检查库存endpoint
const CheckPriceEndpoint = "http://121.40.28.56/topamazon/checkAsinApi.php"


func GetCheckPriceTask(limit int) (task map[string]interface{}) {
	client := GetHttpClient(nil, nil, "", "")
	resp, _ := client.R().SetFormData(map[string]string{
		"action": "getTask",
		"limit": strconv.Itoa(limit),
	}).Post(CheckPriceEndpoint)

	json.Unmarshal(resp.Body(), &task)

	return
}

func FeedBackCheckPriceTask(task, html string) (feedback map[string]interface{}) {
	client := GetHttpClient(nil, nil, "", "")
	resp, _ := client.R().SetFormData(map[string]string{
		"action": "feedback",
		"html": html,
		"task": task,
	}).Post(CheckPriceEndpoint)

	json.Unmarshal(resp.Body(), &feedback)

	return
}
